home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Icon 8.1 / msm-1 / icont.sit / link.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-19  |  5.3 KB  |  153 lines  |  [TEXT/MPS ]

  1. /*
  2.  * External declarations for the linker.
  3.  */
  4.  
  5. #include "::h:rt.h"
  6.  
  7. #ifdef ATT3B
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #endif                    /* ATT3B */
  11.  
  12. /*
  13.  * Miscellaneous external declarations.
  14.  */
  15.  
  16. extern FILE *infile;        /* current input file */
  17. extern FILE *outfile;        /* linker output file */
  18. extern FILE *dbgfile;        /* debug file */
  19. extern char inname[];        /* input file name */
  20. extern int lineno;        /* source program line number (from ucode) */
  21.  
  22. #ifdef EventMon
  23. extern int colmno;        /* source program column number */
  24. #endif                    /* EventMon */
  25.  
  26. extern int lstatics;        /* total number of statics */
  27. extern int argoff;        /* stack offset counter for arguments */
  28. extern int dynoff;        /* stack offset counter for locals */
  29. extern int static1;        /* first static in procedure */
  30. extern int nlocal;        /* number of locals in local table */
  31. extern int nconst;        /* number of constants in constant table */
  32. extern int nrecords;        /* number of records in program */
  33. extern int trace;        /* initial setting of &trace */
  34. extern char ixhdr[];        /* header line for direct execution */
  35. extern char *iconx;        /* location of iconx */
  36. extern int hdrloc;        /* location to place hdr block at */
  37. extern struct lfile *llfiles;    /* list of files to link */
  38.  
  39. /*
  40.  * Structures for symbol table entries.
  41.  */
  42.  
  43. struct lentry {            /* local table entry */
  44.    word  l_name;        /*   index into string space of variable name */
  45.    int l_flag;            /*   variable flags */
  46.    union {            /*   value field */
  47.       int staticid;        /*     unique id for static variables */
  48.       word offset;        /*       stack offset for args and locals */
  49.       struct gentry *global;    /*     global table entry */
  50.       } l_val;
  51.    };
  52.  
  53. struct gentry {            /* global table entry */
  54.    struct gentry *g_blink;    /*    link for bucket chain */
  55.    word g_name;            /*   index into string space of variable name */
  56.    int g_flag;            /*   variable flags */
  57.    int g_nargs;            /*   number of args or fields */
  58.    int g_procid;        /*   procedure or record id */
  59.    word g_pc;            /*   position in icode of object */
  60.    int g_index;            /*   "index" in global table */
  61.    struct gentry *g_next;    /*   next global in table */
  62.    };
  63.  
  64. struct centry {            /* constant table entry */
  65.    int c_flag;            /*   type of literal flag */
  66.    union xval c_val;        /*   value field */
  67.    int c_length;        /*   length of literal string */
  68.    word c_pc;            /*   position in icode of object */
  69.    };
  70.  
  71. struct ientry {            /* identifier table entry */
  72.    struct ientry *i_blink;    /*    link for bucket chain */
  73.    word i_name;            /*   index into string space of string */
  74.    int i_length;        /*   length of string */
  75.    };
  76.  
  77. struct fentry {            /* field table header entry */
  78.    struct fentry *f_blink;    /*    link for bucket chain */
  79.    word f_name;            /*   index into string space of field name */
  80.    int f_fid;            /*   field id */
  81.    struct rentry *f_rlist;    /*    head of list of records */
  82.    struct fentry *f_nextentry;    /*   next field name in allocation order */
  83.    };
  84.  
  85. struct rentry {            /* field table record list entry */
  86.    struct rentry *r_link;    /*   link for list of records */
  87.    int r_recid;            /*   record id */
  88.    int r_fnum;            /*   offset of field within record */
  89.    };
  90.  
  91. #include "lfile.h"
  92.  
  93. /*
  94.  * Flag values in symbol tables.
  95.  */
  96.  
  97. #define F_Global        01    /* variable declared global externally */
  98. #define F_Proc            05    /* procedure (includes GLOBAL) */
  99. #define F_Record       011    /* record (includes GLOBAL) */
  100. #define F_Dynamic       020    /* variable declared local dynamic */
  101. #define F_Static       040    /* variable declared local static */
  102. #define F_Builtin      0101    /* identifier refers to built-in procedure */
  103. #define F_ImpError      0400    /* procedure has default error */
  104. #define F_Argument     01000    /* variable is a formal parameter */
  105. #define F_IntLit     02000    /* literal is an integer */
  106. #define F_RealLit     04000    /* literal is a real */
  107. #define F_StrLit    010000    /* literal is a string */
  108. #define F_CsetLit    020000    /* literal is a cset */
  109.  
  110. /*
  111.  * Symbol table region pointers.
  112.  */
  113.  
  114. extern struct gentry **lghash;    /* hash area for global table */
  115. extern struct ientry **lihash;    /* hash area for identifier table */
  116. extern struct fentry **lfhash;    /* hash area for field table */
  117.  
  118. extern struct lentry *lltable;    /* local table */
  119. extern struct centry *lctable;    /* constant table */
  120. extern struct ipc_fname *fnmtbl; /* table associating ipc with file name */
  121. extern struct ipc_line *lntable; /* table associating ipc with line number */
  122. extern char *lsspace;        /* string space */
  123. extern word *labels;        /* label table */
  124. extern char *codeb;        /* generated code space */
  125.  
  126. extern struct ipc_fname *fnmfree; /* free pointer for ipc/file name tbl */
  127. extern struct ipc_line *lnfree;    /* free pointer for ipc/line number tbl */
  128. extern word lsfree;        /* free index for string space */
  129. extern char *codep;        /* free pointer for code space */
  130.  
  131. extern struct fentry *lffirst;    /* first field table entry */
  132. extern struct fentry *lflast;    /* last field table entry */
  133. extern struct gentry *lgfirst;    /* first global table entry */
  134. extern struct gentry *lglast;    /* last global table entry */
  135.  
  136.  
  137. /*
  138.  * Hash computation macros.
  139.  */
  140.  
  141. #define ghasher(x)    (((word)x)&gmask)    /* for global table */
  142. #define fhasher(x)    (((word)x)&fmask)    /* for field table */
  143.  
  144. /*
  145.  * Machine-dependent constants.
  146.  */
  147.  
  148. #ifdef MultiThread
  149. #define RkBlkSize(gp) ((10*WordSize)+(gp)->g_nargs * sizeof(struct descrip))
  150. #else                    /* MultiThread */
  151. #define RkBlkSize(gp) ((9*WordSize)+(gp)->g_nargs * sizeof(struct descrip))
  152. #endif                    /* MultiThread */
  153.